package com.kobe.game_60;

import java.math.BigDecimal;

public class _56 {
    public static void main(String[] args) {
        int maxSumOfDigit = 0;
        for (int a = 1; a < 100; a++) {
            for (int b = 1; b < 100; b++) {
                BigDecimal bA = new BigDecimal(a);
                bA = bA.pow(b);
                int sum = 0;
                for (char temp : bA.toString().toCharArray()) {
                    sum += Character.getNumericValue(temp);
                    if (sum > maxSumOfDigit) {
                        maxSumOfDigit = sum;
                    }
                }
            }
        }
        System.out.println(maxSumOfDigit);
    }
}
